<template>
  <div class="feedback">
    <div class="main">
      <div class="title">意见与反馈</div>
      <van-form @submit="onSubmit">
        <van-field
          v-model="formData.content"
          rows="2"
          autosize
          label="留言"
          type="textarea"
          maxlength="150"
          placeholder="请输入留言"
          show-word-limit
        />
        <van-field
          v-model="formData.phone"
          label="联系方式"
          placeholder="邮箱/手机号/微信号"
        />
        <div style="margin: 16px">
          <van-button block type="info" native-type="submit" color="#b4282d"
            >提交</van-button
          >
        </div>
      </van-form>
    </div>
  </div>
</template>
<script>
import { submitAction } from "@/api/my/feedback/index";
export default {
  data() {
    return {
      formData: {
        content: "",
        phone: "",
      },
    };
  },
  methods: {
    onSubmit() {
      let userInfo = JSON.parse(localStorage.getItem("userInfo"));
      submitAction({
        ...this.formData,
        name: userInfo.nickName,
        openId: localStorage.getItem("openId"),
      }).then((res) => {
        if (res.data.data) {
          this.$toast("提交成功");
          this.formData = {
            content: "",
            phone: "",
          };
        }
      });
    },
  },
};
</script>
<style lang="scss" scoped>
@import "./index.scss";
</style>
